Work around broken Sportrak firmware and malformed PMGNRTE sentences..
authorrobertl <robertl>
Thu, 15 Nov 2007 19:19:25 +0000 (19:19 +0000)
committerrobertl <robertl>
Thu, 15 Nov 2007 19:19:25 +0000 (19:19 +0000)
magproto.c

index 2ada5e14a65a6a9fc226cd117cfd9accbf1c4316..1f996b603f0a1994dd3a9d4b8064f72eaf14549f 100644 (file)
@@ -30,6 +30,7 @@ static int bitrate = 4800;
 static int wptcmtcnt;
 static int wptcmtcnt_max;
 static int explorist;
+static int broken_sportrak;
 #define MYNAME "MAGPROTO"
 #define MAXCMTCT 200
 
@@ -369,6 +370,11 @@ mag_verparse(char *ibuf)
                        break;
                }
        }
+
+       if (prodid == 37) {
+               broken_sportrak = 1;
+       }
+
        switch (pp->model) {
                case mm_gps315320:
                case mm_map410:
@@ -1027,6 +1033,20 @@ mag_rteparse(char *rtemsg)
                rte_elem->wpt_icon = xstrdup(abuf);
 
                ENQUEUE_TAIL(&mag_rte_head->Q, &rte_elem->Q);
+
+               /* Sportrak (the non-mapping unit) creates malformed
+                * RTE sentence with no icon info after the routepoint
+                * name.  So if we saw an "icon" treat that as new 
+                * routepoint.
+                */
+               if (broken_sportrak && abuf[0]) {
+                       rte_elem = xcalloc(sizeof (*rte_elem),1);
+                       QUEUE_INIT(&rte_elem->Q);
+                       rte_elem->wpt_name = xstrdup(abuf);
+
+                       ENQUEUE_TAIL(&mag_rte_head->Q, &rte_elem->Q);
+               }
+
                next_stop[0] = 0;
                currtemsg += n;
        }